import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class Main {

    public static void main(String[] args) {

        ExecutorService executor = Executors.newFixedThreadPool(10);

        CompletableFuture<String> taskB = CompletableFuture.supplyAsync(() -> {
            String id = UUID.randomUUID().toString();
            System.out.println("执行任务A：" + id + "," + Thread.currentThread().getName());
            return id;
        }).thenApplyAsync(result -> {
            System.out.println("任务B获取到任务A结果：" + result + "," + Thread.currentThread().getName());
            result = result.replace("-", "");
            return result;
        },executor);

        System.out.println("main线程拿到结果：" + taskB.join());
    }
    public ListNode removeNthFromEnd(ListNode head, int n) {
        //虚拟化一个节点，防止空数组越界
        ListNode dummy = new ListNode(0);
        dummy.next = head;

        ListNode prev = dummy;
        ListNode cur = dummy;
        for(int i = 01; i <= n; i++) {
            prev=prev.next;
        }
        while(prev != null) {
            prev=prev.next;
            cur=cur.next;
        }
        cur.next=cur.next.next;
        return dummy.next;
    }
    static class ListNode {
     int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }


}